package com.noble.meether.ui.reg.splash;

import android.os.Bundle;
import android.support.annotation.Nullable;

import com.noble.glamour.module.logic.application.App;
import com.noble.glamour.module.logic.application.ModuleMgr;
import com.noble.glamour.module.util.UIShow;
import com.noble.library.base.BaseAppCompatActivity;
import com.noble.library.observe.MsgMgr;
import com.noble.library.observe.MsgType;

/**
 * 闪屏页面
 */
public class SplashActivity extends BaseAppCompatActivity {
    private final static long delayTime = 2000;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        isCanBack(false);
        setCanNotify(false);//设置该页面不弹出悬浮窗消息通知
        super.onCreate(savedInstanceState);

        init();
    }

    // 不可删除，检测手机是否可沉浸式
    @Override
    protected boolean isImmersionBar() {
        return true;
    }

    // 不可删除；初始化 StatusBarUtil.statusChangeable 字段
    @Override
    protected boolean isStatusBarLight() {
        return true;
    }

    private void init() {
        initData();

        int delay = (int) (delayTime - (System.currentTimeMillis() - App.t));
        MsgMgr.getInstance().delay(this, this::skipLogic, delay);
    }

    private void initData() {
        //ModuleMgr.getCommonMgr().requestStaticConfig();//请求一些在线配置信息
    }

    /**
     * Intent跳转
     */
    private void skipLogic() {
        if (ModuleMgr.getLoginMgr().checkAuthIsExist()) {
            MsgMgr.getInstance().sendMsg(MsgType.MT_App_Login, true);
            UIShow.showMainClearTask(this);
        } else {
            UIShow.showNavUserAct(this);
            finish();
        }
    }

    @Override
    public void onBackPressed() {
        // 空实现，不响应返回键点击
    }
}
